package test;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;

public class fourone {

	private static void remove(List<String> list, String word) {
		for (Iterator<String> iterator = list.iterator(); iterator.hasNext();) {
			String str = (String) iterator.next();
			if (str.equals(word))
				iterator.remove();
		}

	}

	private static List<String> convertStringToList(String nextLine) {
		List<String> list = new ArrayList<String>();
		Scanner input = new Scanner(nextLine);
		while (input.hasNext()) {
			list.add(input.next());
		}
		input.close();
		return list;
	}

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		while (input.hasNextLine()) {
			List<String> list = convertStringToList(input.nextLine());
			System.out.println(list);
			String word = input.nextLine();
			remove(list, word);
			System.out.println(list);
		}
		input.close();
	}

}